﻿using System.Windows;
using Mandarine.MVVM.Command;
using Mandarine.Util;

namespace DataBindApp1.Command
{
    public class MessageBoxCommand : RelayCommand<string>
    {
        public string Title { get; set; }
        public MessageBoxResult Result { get; set; }

        /// <summary>
        /// XAMLにはデフォルトコンストラクタが必要
        /// </summary>
        public MessageBoxCommand()
            : base(null)
        {
            _execute = message =>
            {
                var currentPage = Util.GetActivePage();

                if ( Title.IsNotEmpty() )
                    Title = currentPage.ToString();
                Result = 
                    MessageBox.Show(message, Title, MessageBoxButton.OKCancel);
            };
        }

    }
}